package com.yiexia.springtest;

import com.yiexia.springtest.bean.Person;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

/**
 * @program: spring
 * @description: test
 * @author: wjp
 * @create: 2021-05-14 11:15
 **/
public class MyApplication {

	public static void main(String[] args) {
		/**
		 * 	new ClassPathResource("applicationContent.xml")
		 * 	1.设置资源路径  检查路径
		 * 	2.设置类加载器  获取类加载器
		 *
		 *  new XmlBeanFactory(Resource resource)
		 * 	super(parentBeanFactory);
		 * 	this.reader.loadBeanDefinitions(resource);
		 * 	1.使用父类的构造方法创建 DefaultListableBeanFactory
		 * 	2. 使用自身的 reader = new XmlBeanDefinitionReader(this) 加载bean定义
		 */
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("applicationContent.xml"));

		Person person = (Person) beanFactory.getBean("person");

		System.out.println(person);

	}
}
